package com.starview.platform.data.type;

import java.util.Set;
import java.util.TreeSet;

public class BindingLocations extends AbstractTypeVisitor
{
  private Set<Location> bindingLocations = new TreeSet<Location>();

  public static Set<Location> bindingLocations(IType type)
  {
    BindingLocations visitor = new BindingLocations();
    type.accept(visitor);
    return visitor.bindingLocations;
  }

  @Override
  public void visitSimpleType(Type t)
  {
  }

  @Override
  public void visitTypeVar(TypeVar v)
  {
    if (v.isBound()) {
      Location loc = v.getBindingLocation();
      if (loc != null)
        bindingLocations.add(loc);
      v.getBoundValue().accept(this);
    }
  }
}
